.so ../bk-macros
.TH "bk service" "\*[BKVER]" %E% "\*(BC" "\*(UM"
.SH NAME
bk service \- manage a bkd as a Windows service
.SH SYNOPSIS
.B bk service install
.[ARG] name
.[ARG] bkdargs
.br
.B bk service uninstall
.[B] \-a
.[ARG] name
.br
.B bk service status
.[B] \-a
.ARG name
.br
.B bk service list
.SH DESCRIPTION
.LP
The \*[BK] daemon,
.BR bkd ,
is used to synchronize and query repositories.
See
.B bk help bkd
for information on the \*(BK daemon.
.LP
.B bk service
is used to install (and start), uninstall (after stopping), query the status
of a named \*(BK daemon (\c
.BR bkd ),
or list all installed daemons.
The main reason for using this interface is to get a service that will be
restarted on each boot.
.SH MULTIPLE DAEMONS
It is possible to install more than one \*(BK daemon, which is useful if
you want different permissions on different repositories.
All daemons must have a name, and the name must be unique across the 
set of \*(BK daemons.
The default name is \*(lq\s-1BKD\s0\*(rq.
The names are stored in the registry and we suggest a single word, using mixed
case if you want to a name like \*(lqMyBitkeeperDaemon\*(rq.
.LP
Some commands take an optional 
.Q \-a
instead of a name which 
means operate on all installed \*(BK daemons.
.SH PERMISSIONS
By default, an installed service is run as LocalSystem which is a system 
user, not the user who installed the service.  This can lead to problems
if the
.SM BKD
is used to serve up repositories created by the user with
permissions restrictive enough that the LocalSystem user cannot access
some or all the files in the repository.
.LP
There are two ways around this problem, either create all the repositories
through the
.SM BKD
so they are all owned by LocalSystem, or change the service
to be run as the user who owns the repositories, described below.
.SH RUNNING AS A SPECIFIC USER
.LI
The user account must have a password.  If not, go to 
.QR "Control Panel\->User Accounts" ,
select the user, and create a password.
Close that window.
.li
The user account must be allowed to log on as a service.  This is not
on by default, so go to
.Q Control Panel\->Administrative Tools\->Local Security Policy\->Local Policies
and double click on
.QR "User Rights Assignments" .
Find
.Q Log on as a service
and double click that.  Click
.Q Add User or Group
and add the user.
Close that window.
.li
The service needs to be modified to run as the user.  Go to
.QR "Control Panel\->Administrative Tools\->Services" ,
find the \*(BK daemon, double-click it.
Click
.Q Stop
to stop the service, then click the
.Q Log On
tab, change from
.Q Local System account
to the user, entering the password as well.
Click
.QR Apply .
Click the 
.Q General
tab and then click
.QR Start .
The daemon will restart as the selected user.
.LP
After installing a service it is a good idea to test that it works by 
trying a clone, pull, and/or changes from a client.
.SH NOTES
This interface works only on Windows.
.LP
Environment variables must be explicitly passed on the
.B bkd
options list, i.e.,
.DS
bk service DOCS -EBK_USER=docs -p8000
.DE
.LP
The
.B bkd
service does not work when started from a network drive.
.LP
The
.B bkd
service does not work when started from a subst'ed drive.
.LP
bk uninstall may require a reboot in order to completely remove the
service.
.SH "SEE ALSO"
.SA bkd
.SA Howto-bkd
.SH CATEGORY
.B Repository
.br
.B Admin
